<template>
  <div class="common-layout">
    <el-container>
      <el-header>
        <div class="hea">商家管理端</div>
      </el-header>
      <el-container>
        <el-aside width="200px">
          <el-menu
            @open="handleOpen"
            @close="handleClose"
            :router="true"
            unique-opened
            :default-active="$route.path"
            class="el-menu-vertical-demo"
          >
            <el-sub-menu v-for="(item, i) in menu" :key="i" :index="item.id">
              <template #title>
                <i class="el-icon-s-fold"></i>
                <span>{{ item.name }}</span>
              </template>
              <el-menu-item
                v-for="(items, index) in item.children"
                :key="index"
                :index="items.path"
                >{{ items.text }}
              </el-menu-item>
            </el-sub-menu>
          </el-menu>
        </el-aside>
        <el-main>
          <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>
<script setup>
import { reactive } from "vue";
const menu = reactive([
  {
    name: "商品管理",
    id: "2",
    children: [{ text: "商品列表", path: "/goods" }],
  },
]);
const handleOpen = (key, keyPath) => {
  console.log(key, keyPath);
};
const handleClose = (key, keyPath) => {
  console.log(key, keyPath);
};
</script>

<style scoped>
.common-layout {
  width: 100%;
  height: 100%;
  background-color: #e9eef3;
}
.el-header {
  background-color: #252a3d;
  color: #fff;
  text-align: center;
}
.logo {
  width: 40px;
  height: 40px;
  margin-top: 10px;
  float: left;
  margin-right: 10px;
}
.hea {
  float: left;
  height: 60px;
  line-height: 60px;
  color: #fff;
  font-weight: bold;
  font-size: 24px;
}
.el-aside {
  background-color: #d3dce6;
  color: #333;
  text-align: center;
  height: calc(100vh - 60px);
}
.el-menu {
  height: 100%;
}
.el-submenu {
  text-align: left;
}
.el-menu-item {
  text-align: left;
}
.el-main {
  background-color: #fff;
  color: #333;
  height: calc(100vh - 100px);
  margin: 20px;
}
</style>
